# Xiang GAO, 2014.5

# Version required
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )

# Project Name
PROJECT( slam3d_gx )

# Basic Settings
SET(CMAKE_CXX_COMPILER "g++")
SET(CMAKE_CXX_FLAGS "")
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

# Debug Settings
SET( CMAKE_BUILD_TYPE Release )

# Include directories
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/include )

# Library directories
LINK_DIRECTORIES( ${PROJECT_SOURCE_DIR}/lib )

# Add new CMake Modules
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

# Extra libraries
# G2O
SET(G2O_ROOT "/usr/local/include/g2o")

FIND_PACKAGE(G2O)
IF(G2O_FOUND)

ELSE(G2O_FOUND)
  MESSAGE(FATAL_ERROR "g2o not FOUND.")
ENDIF(G2O_FOUND)

# Eigen3
FIND_PACKAGE(Eigen3)
IF(EIGEN3_FOUND)
  MESSAGE(STATUS ${EIGEN3_INCLUDE_DIR})
ELSE(EIGEN3_FOUND)
  MESSAGE(FATAL_ERROR "EIGEN3 not FOUND.")
ENDIF(EIGEN3_FOUND)

# CSparse
FIND_PACKAGE(CSparse)
IF(CSPARSE_FOUND)
  SET(BUILD_CSPARSE OFF CACHE BOOL "Build local CSparse library")
ELSE(CSPARSE_FOUND)
  SET(BUILD_CSPARSE ON CACHE BOOL "Build local CSparse library")
  IF(BUILD_CSPARSE)
    SET(CSPARSE_FOUND TRUE)
  ENDIF()
ENDIF(CSPARSE_FOUND)

# PCL
find_package(PCL 1.4 REQUIRED COMPONENTS common io filters registration sample_consensus segmentation )
IF(PCL_FOUND)
	MESSAGE(STATUS "PCL found in " ${PCL_INCLUDE_DIRS})
ELSE(PCL_FOUND)
	MESSAGE(FATAL_ERROR "PCL NOT FOUND" )
ENDIF(PCL_FOUND)

ADD_DEFINITIONS(${PCL_DEFINITIONS})
ADD_DEFINITIONS(-Wno-deprecated -DEIGEN_DONT_VECTORIZE -DEIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)

# Source directories
ADD_SUBDIRECTORY( ${PROJECT_SOURCE_DIR}/src )
